home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dr. Windows 3
/
dr win3.zip
/
dr win3
/
PROGRAMR
/
UPC12BS1.ZIP
/
UUCICO
/
DCPXFER.C
< prev
next >
Wrap
C/C++ Source or Header
|
1993-10-02
|
52KB
|
1,420 lines
/*--------------------------------------------------------------------*/
/* d c p x f e r . c */
/* */
/* Procotol independent transfer level for UUCICO */
/* */
/* Stuart Lynne May/87 */
/* */
/* Copyright (c) Richard H. Lamb 1985, 1986, 1987 */
/* Changes Copyright (c) Stuart Lynne 1987 */
/* Changes Copyright (c) Jordan Brown 1990, 1991 */
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
/* Changes Copyright (c) 1989-1993 by Kendra Electronic */
/* Wonderworks. */
/* */
/* All rights reserved except those explicitly granted by */
/* the UUPC/extended license agreement. */
/*--------------------------------------------------------------------*/
/*
* $Id: dcpxfer.c 1.24 1993/10/02 22:56:59 ahd Exp $
*
* $Log: dcpxfer.c $
* Revision 1.24 1993/10/02 22:56:59 ahd
* Suppress compile warning
*
* Revision 1.23 1993/09/23 03:26:51 ahd
* Don't allow remote sites to send call files!
*
* Revision 1.22 1993/09/20 04:46:34 ahd
* OS/2 2.x support (BC++ 1.0 support)
* TCP/IP support from Dave Watt
* 't' protocol support
*
* Revision 1.21 1993/09/02 12:08:17 ahd
* HPFS Support
*
* Revision 1.20 1993/08/08 17:39:09 ahd
* Denormalize path for opening on selected networks
*
* Revision 1.19 1993/07/22 23:22:27 ahd
* First pass at changes for Robert Denny's Windows 3.1 support
*
*
* Revision 1.17 1993/05/30 00:04:53 ahd
* Multiple communications drivers support
*
* Revision 1.16 1993/05/09 03:41:47 ahd
* Don't expand path of files destined for UUCP spool
* Correct syslog processing to not close when not multitasking
*
* Revision 1.15 1993/05/06 03:41:48 ahd
* Reformat syslog output into readable format
* parse userids off incoming commands again
*
* Revision 1.14 1993/04/11 00:34:11 ahd
* Global edits for year, TEXT, etc.
*
* Revision 1.13 1993/04/10 21:25:16 dmwatt
* Add Windows/NT support
*
* Revision 1.12 1993/04/05 04:35:40 ahd
* Allow unique send/receive packet sizes
*
* Revision 1.11 1993/01/23 19:08:09 ahd
* Don't enable unbuffered I/O twice if not multitask mode
*
* Revision 1.10 1992/12/01 04:37:03 ahd
* Suppress routine names transfered from debug level 0 and 1
*
* Revision 1.9 1992/11/29 22:09:10 ahd
* Change size_t to int to suppress warning message
*
* Revision 1.8 1992/11/28 19:51:16 ahd
* If in multitask mode, only open syslog on demand basis
*
* Revision 1.7 1992/11/22 21:20:45 ahd
* Make databuf char rather than unsigned char
*
* Revision 1.6 1992/11/20 12:39:10 ahd
* Add instead of substracting on the receive buffer!
*
* Revision 1.5 1992/11/19 03:01:31 ahd
* drop rcsid
*
* Revision 1.4 1992/11/19 02:36:12 ahd
* Insure log file is flushed
*
* Revision 1.3 1992/11/17 13:44:24 ahd
* Drop command[BUFSIZ], using databuf instead.
*
* Revision 1.2 1992/11/15 20:09:50 ahd
* Use unbuffered files to eliminate extra data copy
* Clean up modem file support for different protocols
*
*/
/*
Additional maintenance Notes:
01Nov87 - that strncpy should be a memcpy! - Jal
22Jul90 - Add check for existence of the file before writing
it. ahd
09Apr91 - Add numerous changes from H.A.E.Broomhall and Cliff
Stanford for bidirectional support ahd
05Jul91 - Merged various changes from Jordan Brown's (HJB)
version of UUPC/extended to clean up transmission
of commands, etc. ahd
09Jul91 - Rewrite to use unique routines for all four kinds of
transfers to allow for testing and security ahd
*/
/*--------------------------------------------------------------------*/
/* System include files */
/*--------------------------------------------------------------------*/
#include <ctype.h>
#include <fcntl.h>
#include <direct.h>
#include <io.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/timeb.h>
/*--------------------------------------------------------------------*/
/* UUPC/extended include files */
/*--------------------------------------------------------------------*/
#include "lib.h"
#include "dcp.h"
#include "dcpsys.h"
#include "dcpxfer.h"
#include "expath.h"
#include "hlib.h"
#include "hostable.h"
#include "import.h"
#include "security.h"
#include "modem.h"
/*--------------------------------------------------------------------*/
/* Global variables */
/*--------------------------------------------------------------------*/
static char *databuf = NULL;
static unsigned int xferBufSize = 0;
static char fName[FILENAME_MAX], tName[FILENAME_MAX], dName[FILENAME_MAX];
static char *lName; // Name to report in syslog
static char type, cmdopts[16];
static long bytes;
static struct timeb startTime;
static boolean spool = FALSE; /* Received file is into spool dir */
static char spolName[FILENAME_MAX];
/* Final host name of file to be
received into spool directory */
static char tempName[FILENAME_MAX];
/* Temp name used to create received
file */
static char userid[20];
currentfile();
/*--------------------------------------------------------------------*/
/* Internal function prototypes */
/*--------------------------------------------------------------------*/
static boolean pktgetstr( char *s);
static boolean pktsendstr( char *s );
static void buf_init( void );
static int bufill(char *buffer);
static int bufwrite(char *buffer,int len);
/*************** SEND PROTOCOL ***************************/
/*--------------------------------------------------------------------*/
/* s d a t a */
/* */
/* Send File Data */
/*--------------------------------------------------------------------*/
XFER_STATE sdata( void )
{
int S_size;
int used = 0;
S_size = bufill((char *) databuf);
if (S_size == 0) /* Get data from file */
return XFER_SENDEOF; /* if EOF set state to that */
else if (S_size == -1) /* If error ... */
return XFER_ABORT; /* Toss file */
do {
short xmit = min( (size_t) S_size - used , s_pktsize );
if ((*sendpkt)((char *) databuf + used, xmit) != DCP_OK)
/* Send data fail? */
{
fclose( xfer_stream );
xfer_stream = NULL;
return XFER_LOST; /* Trouble! */
}
else
used += xmit;
} while( S_size > used );
return XFER_SENDDATA; /* Remain in send state */
} /*sdata*/
/*--------------------------------------------------------------------*/
/* b u f i l l